package com.airbnb.lottie.model.animatable;

import com.airbnb.lottie.animation.keyframe.BaseKeyframeAnimation;
import com.airbnb.lottie.animation.keyframe.PathKeyframeAnimation;
import com.airbnb.lottie.animation.keyframe.PointKeyframeAnimation;
import com.airbnb.lottie.value.Keyframe;
import ohos.agp.utils.Point;

import java.util.Collections;
import java.util.List;

public class AnimatablePathValue implements AnimatableValue<Point, Point> {
    private final List<Keyframe<Point>> keyframes;

    /**
     * Create a default static animatable path.
     */
    public AnimatablePathValue() {
        keyframes = Collections.singletonList(new Keyframe<>(new Point(0, 0)));
    }

    public AnimatablePathValue(List<Keyframe<Point>> keyframes) {
        this.keyframes = keyframes;
    }

    @Override
    public List<Keyframe<Point>> getKeyframes() {
        return keyframes;
    }

    @Override
    public boolean isStatic() {
        return keyframes.size() == 1 && keyframes.get(0).isStatic();
    }

    @Override
    public BaseKeyframeAnimation<Point, Point> createAnimation() {
        if (keyframes.get(0).isStatic()) {
            return new PointKeyframeAnimation(keyframes);
        }
        return new PathKeyframeAnimation(keyframes);
    }
}